package com.sc.nft.admin.controller;

import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.PopupAnnouncementAdminAddDTO;
import com.sc.nft.entity.dto.PopupAnnouncementAdminModificationDTO;
import com.sc.nft.entity.vo.PopupAnnouncementAdminVO;
import com.sc.nft.service.PopupAnnouncementService;
import com.sc.nft.sup.PageRequest;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * app维护以及维护完成的弹窗表(PopupAnnouncement)表控制层
 *
 * @author wwc
 * @since 2023-07-05 17:14:53
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/popupAnnouncement")
@Api(tags = "产品维护")
public class PopupAnnouncementController {

    /**
     * 服务对象
     */
    private final PopupAnnouncementService popupAnnouncementService;

    @PostMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取列表", notes = "获取列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<PopupAnnouncementAdminVO> getPage(@RequestBody PageRequest pageRequest) {
        return PageResult.success(popupAnnouncementService.getPage(pageRequest));
    }

    @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "新增数据", notes = "新增数据", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result add(@RequestBody PopupAnnouncementAdminAddDTO popupAnnouncementAdminAddDTO) {
        popupAnnouncementService.add(popupAnnouncementAdminAddDTO);
        return Result.success();
    }

    @PostMapping(value = "/modification", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "修改数据", notes = "修改数据", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result modification(@RequestBody PopupAnnouncementAdminModificationDTO popupAnnouncementAdminModificationDTO) {
        popupAnnouncementService.modification(popupAnnouncementAdminModificationDTO);
        return Result.success();
    }

    @PostMapping(value = "/removeById", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "根据id删除数据", notes = "根据id删除数据", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result remove(@RequestBody IdRequest idRequest) {
        popupAnnouncementService.removeById(idRequest.getId());
        return Result.success();
    }

}
